<?php

$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game WHERE game_id=".$_POST['game_id'];
	$RsgameSql = $UserManagerObjAjax->GetRecords("Row",$SelectgameSql);
	
	if(is_array($RsgameSql) && count($RsgameSql)){
		$string = '';
		if($RsgameSql['is_ladder'] == 'Y'){
			$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game_ladder WHERE game_id='" . $_POST['game_id'] . "' AND is_active='Y' ORDER BY ladder_name";
			$RsLadderSql = $UserManagerObjAjax->GetRecords("All",$SelectgameSql);
			if(is_array($RsLadderSql) && count($RsLadderSql)){
				$string .= '<label for="ladder_id">Select Ladder: </label><select name="ladder_id" id="ladder_id" class="con-req">'; 
				for($i=0; $i<count($RsLadderSql); $i++){
					$sel = isset($Formval) && $Formval['ladder_id'] == $RsLadderSql[$i]['ladder_id'] ? "selected" : "";
					$string .= '<option value="'.$RsLadderSql[$i]['ladder_id'].'" '.$sel.'>'.$RsLadderSql[$i]['ladder_name'].'</option>';
				}
				$string .= '</select>';
			}
			//$string .= '<p class="clear"></p>';
			$string .= '<br class="clear" />';
		}
		if($RsgameSql['is_race'] == 'Y'){
			$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game_race WHERE game_id='" . $_POST['game_id'] . "' AND is_active='Y' ORDER BY race_title";
			$RsLadderSql = $UserManagerObjAjax->GetRecords("All",$SelectgameSql);
			if(is_array($RsLadderSql) && count($RsLadderSql)){
				$string .= '<label for="race_id">Select Race: </label>'; 
				for($i=0; $i<count($RsLadderSql); $i++){
					$sel = isset($Formval) && in_array($RsLadderSql[$i]['race_id'],$raceArray) ? "checked" : "";
					$string .= '<input type="checkbox" name="race_id[]" value="'.$RsLadderSql[$i]['race_id'].'" '.$sel.' />&nbsp;'.$RsLadderSql[$i]['race_title'] . "&nbsp;&nbsp;";
				}				
			}
			//$string .= '<p class="clear"></p>';
			$string .= '<br class="clear" />';
		}
		if($RsgameSql['is_server'] == 'Y'){
			$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game_server WHERE game_id='" . $_POST['game_id'] . "' AND is_active='Y' ORDER BY server_name";
			$RsLadderSql = $UserManagerObjAjax->GetRecords("All",$SelectgameSql);
			if(is_array($RsLadderSql) && count($RsLadderSql)){
				$string .= '<label for="server_id">Select Server: </label>'; 
				for($i=0; $i<count($RsLadderSql); $i++){
					$sel = isset($Formval) && in_array($RsLadderSql[$i]['server_id'],$serverArray) ? "checked" : "";
					$string .= '<input type="checkbox" name="server_id[]" value="'.$RsLadderSql[$i]['server_id'].'" '.$sel.' />&nbsp;'.$RsLadderSql[$i]['server_name'] . "&nbsp;&nbsp;";					
				}				
			}
			//$string .= '<p class="clear"></p>';
			$string .= '<br class="clear" />';
		}
		if($RsgameSql['is_region'] == 'Y'){
			$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game_region WHERE game_id='" . $_POST['game_id'] . "' AND is_active='Y' ORDER BY region_title";
			$RsLadderSql = $UserManagerObjAjax->GetRecords("All",$SelectgameSql);
			if(is_array($RsLadderSql) && count($RsLadderSql)){
				$string .= '<label for="region_id">Select Region: </label>'; 
				for($i=0; $i<count($RsLadderSql); $i++){
					$sel = isset($Formval) && in_array($RsLadderSql[$i]['region_id'],$regionArray) ? "checked" : "";
					$string .= '<input type="checkbox" name="region_id[]" value="'.$RsLadderSql[$i]['region_id'].'" '.$sel.' />&nbsp;'.$RsLadderSql[$i]['region_title'] . "&nbsp;&nbsp;";
				}
			}
			//$string .= '<p class="clear"></p>';
			$string .= '<br class="clear" />';
		}
		if($RsgameSql['is_rating'] == 'Y'){
			$SelectgameSql="SELECT * FROM ".TABLEPREFIX."_game_rating WHERE game_id='" . $_POST['game_id'] . "' AND is_active='Y' ORDER BY rating_title";
			$RsLadderSql = $UserManagerObjAjax->GetRecords("All",$SelectgameSql);
			if(is_array($RsLadderSql) && count($RsLadderSql)){
				$string .= '<label for="rating_id">Select Rating: </label>'; 
				for($i=0; $i<count($RsLadderSql); $i++){
					$sel = isset($Formval) && in_array($RsLadderSql[$i]['rating_id'],$ratingArray) ? "checked" : "";
					$string .= '<input type="checkbox" name="rating_id[]" value="'.$RsLadderSql[$i]['rating_id'].'" '.$sel.' />&nbsp;'.$RsLadderSql[$i]['rating_title'] . "&nbsp;&nbsp;";
				}
			}
			//$string .= '<p class="clear"></p>';
			$string .= '<br class="clear" />';
		}
		echo $string;
	}
	else{
		echo '<span style="color:red">Invalid game choosen!</span>';
	}
?>